#include <stdio.h>
#include <stdlib.h>
#include "search.h"

typedef struct _Person{
    char name[100];
    int age;
} Person;
typedef Person* PP;

//自定义比较函数，将年龄作为关键字段
int ComparePerson(PP p1, PP p2){
    return p1->age - p2->age;
}

int main(){
    PP array[5];
    for (int i = 0; i < 5; i++)
    {
        array[i] = (PP)malloc(sizeof(Person));
    }
    array[0]->age = 3;
    array[1]->age = 15;
    array[2]->age = 32;
    array[3]->age = 50;
    array[4]->age = 66;

    Person key = {.age = 66,};
    int index = BinarySearchRecursively(array,0,4,&key,ComparePerson);
    printf("index:%d\n",index);
    return 0;
}